package com.ocom.mjrecode.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.access.EntityMjRecord;
import com.ocom.common.entity.mjrecode.MjRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MjRecodeMapper extends BaseMapper<MjRecord> {



//	@Select("select com_id as comId , count(id) as mjRecNum   " +
//			"from mj_recode " +
//			"where month_value = #{month} and com_id between  #{beginComId} and  #{endComId} " +
//			"group by com_id " )
//	public List<MjRecCountVo> selectRecCount(@Param("beginComId") Long beginComId,
//											 @Param("endComId")Long endComId ,
//											 @Param("month")String month);

    @Select({"<script>",
            "SELECT" +
                    " *" +
                    " FROM" +
                    " mj_record" +
                    " WHERE" +
                    " com_id = #{comId}" +
                    " AND open_time > #{beginTime}" +
                    " AND (send_state >> (#{target} - 1) &amp; 1) = 0 " +
                    " <when test=\"yearDate.size()>0 \" > "+
                    " AND  " +
                    "<foreach collection='yearDate' item='item' open='(' separator='or' close=')'>" +
                    " month_value = (#{item}) " +
                    "</foreach>"+
                    " </when> "+
                    " ORDER BY " +
                    " open_time DESC " +
                    " LIMIT #{size};"+
                    "</script>"})
    List<MjRecord> getNosendRecord(Long comId, String beginTime, Integer target, Integer size , List<String> yearDate);
}
